﻿using System;
using System.Runtime.InteropServices;

namespace LightController
{
    public class RseeControllerAPI
    {
        [DllImport(@"RseeController.dll", EntryPoint = "RseeController_ConnectNet",
       CallingConvention = CallingConvention.Cdecl)]
        public extern static uint RseeController_ConnectNet(string address, int port);

        [DllImport(@"RseeController.dll", EntryPoint = "RseeController_CloseNet",
               CallingConvention = CallingConvention.Cdecl)]
        public extern static int RseeController_CloseNet(uint socket);

        [DllImport(@"RseeController.dll", EntryPoint = "RseeController_OpenCom",
               CallingConvention = CallingConvention.Cdecl)]
        public extern static int RseeController_OpenCom(string com, int baud, bool overloop);

        [DllImport(@"RseeController.dll", EntryPoint = "RseeController_CloseCom",
               CallingConvention = CallingConvention.Cdecl)]
        public extern static int RseeController_CloseCom(string com, int com_handle);

        [DllImport(@"RseeController.dll", EntryPoint = "RseeController_PM_D_8TE_BRTSetChannel",
               CallingConvention = CallingConvention.Cdecl)]
        public extern static int RseeController_PM_D_8TE_BRTSetChannel(int com, uint socket, int channel, int range);

        [DllImport(@"RseeController.dll", EntryPoint = "RseeController_PM_D_8TE_PLSSetChannel",
               CallingConvention = CallingConvention.Cdecl)]
        public extern static int RseeController_PM_D_8TE_PLSSetChannel(int com, uint socket, int channel, int time);

        [DllImport(@"RseeController.dll", EntryPoint = "RseeController_PM_D_8TE_BRTReadChannel",
               CallingConvention = CallingConvention.Cdecl)]
        public extern static int RseeController_PM_D_8TE_BRTReadChannel(int com, uint socket, int channel);

        [DllImport(@"RseeController.dll", EntryPoint = "RseeController_PM_D_8TE_PLSReadChannel",
               CallingConvention = CallingConvention.Cdecl)]
        public extern static int RseeController_PM_D_8TE_PLSReadChannel(int com, uint socket, int channel);

        [DllImport(@"RseeController.dll", EntryPoint = "RseeController_PM_D_8TE_ChangeMode_New",
               CallingConvention = CallingConvention.Cdecl)]
        public extern static int RseeController_PM_D_8TE_ChangeMode_New(int com, uint socket, int mode);

        [DllImport(@"RseeController.dll", EntryPoint = "RseeController_PM_D_8TE_ChangeMode",
               CallingConvention = CallingConvention.Cdecl)]
        public extern static int RseeController_PM_D_8TE_ChangeMode(int com, uint socket, int mode);

        [DllImport(@"RseeController.dll", EntryPoint = "RseeController_PM_D_8TE_Softtri",
               CallingConvention = CallingConvention.Cdecl)]
        public extern static int RseeController_PM_D_8TE_Softtri(int com, uint socket, bool en1, bool en2, bool en3, bool en4, bool en5, bool en6, bool en7, bool en8);

        [DllImport(@"RseeController.dll", EntryPoint = "RseeController_PM_D_8TE_ReadMode",
               CallingConvention = CallingConvention.Cdecl)]
        public extern static int RseeController_PM_D_8TE_ReadMode(int com, uint socket);

        [DllImport(@"RseeController.dll", EntryPoint = "RseeController_PM_D_8TE_ReadOnoff",
               CallingConvention = CallingConvention.Cdecl)]
        public extern static int RseeController_PM_D_8TE_ReadOnoff(int com, uint socket);

        [DllImport(@"RseeController.dll", EntryPoint = "RseeController_PM_D_8TE_ReadInfo",
               CallingConvention = CallingConvention.Cdecl)]
        public extern static int RseeController_PM_D_8TE_ReadInfo(int com, uint socket, IntPtr arr);

        [DllImport(@"RseeController.dll", EntryPoint = "RseeController_NPC_SetChannel",
               CallingConvention = CallingConvention.Cdecl)]
        public extern static int RseeController_NPC_SetChannel(int com, uint socket, int channel, int range);

        [DllImport(@"RseeController.dll", EntryPoint = "RseeController_PM_D_8TE_BRTSetAll",
 CallingConvention = CallingConvention.Cdecl)]
        public extern static int RseeController_PM_D_8TE_BRTSetAll(int com, uint socket, bool en1, int range1, bool en2, int range2, 
            bool en3, int range3, bool en4, int range4, bool en5, int range5, bool en6, int range6, bool en7, int range7, bool en8, int range8);
    }
}
